package com.zheng.hospital.receiver;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.zheng.hospital.contant.MQConstant;
import com.zheng.hospital.service.SmsService;
import com.zheng.hospital.vo.msm.MsmVo;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class SmsReceiver {
    @Autowired
    private SmsService smsService;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = MQConstant.QUEUE_SMS_ITEM, durable = "true"),
            exchange = @Exchange(value = MQConstant.EXCHANGE_DIRECT_SMS),
            key = {MQConstant.ROUTING_SMS_ITEM}
    ))
    public void send(MsmVo msmVo, Message message, Channel channel){
        smsService.send(msmVo);
    }
}
